import { combineReducers } from "redux";
import TabbarReducer from "./reducer/TabbarReducer";
import CityReducer from "./reducer/CityReducer";
import CinemaListReducer from "./reducer/CinemaListReducer";
import reduxThunk from "redux-thunk";
import { createStore, applyMiddleware, compose } from 'redux';
import {persistStore, persistReducer} from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
    key: 'root',
    storage,
    whitelist:['CityReducer']  //设置某个reducer数据持久化
  }

const reducer = combineReducers({    //合并Reducer
    TabbarReducer,
    CityReducer,
    CinemaListReducer
})

const myPersistReducer = persistReducer(persistConfig, reducer)

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(myPersistReducer, /* preloadedState, */ composeEnhancers(applyMiddleware(reduxThunk)));
const persistor = persistStore(store)

export {store, persistor};